//
//  CZUserAccountModel.swift
//  微博
//
//  Created by 范承志 on 16/6/11.
//  Copyright © 2016年 fanchengzhi. All rights reserved.
//

import UIKit

class CZUserAccountModel: NSObject, NSCoding {
    
    //用户授权的唯一票据
    var access_token: String?
    //access_token的生命周期，单位是秒数
    var expires_in: TimeInterval = 0 {
        
        //当expires_in 被赋值的时候就会走 didSet方法
        didSet{
            
            expires_Date = Date().addingTimeInterval(expires_in)
        }
    }
    //授权用户的UID
    var uid: String?
    //用户昵称
    var screen_name: String?
    //用户头像
    var avatar_large: String?
    //过期时间
    var expires_Date: Date?
    
    override init(){
        super.init()
    }
    //归档
    func encode(with acoder: NSCoder) {
        self.yy_modelEncode(with: acoder)
    }
    //解档
    required init?(coder aDecoder: NSCoder) {
        super.init()
        self.yy_modelInit(with: aDecoder)
    }
    
    override var description: String{
        let keys = ["access_token", "expires_in", "expires_Date", "uid", "screen_name", "avatar_large"]
        return dictionaryWithValues(forKeys: keys).description
    }
}
